﻿using LeanApp.Model;
using System.Collections.Generic;
using System.Linq;

namespace LeanApp.Dao
{
    /// <summary>
    /// 线平衡的处理
    /// </summary>
    public class LineBalanceDao
    {
        /// <summary>
        /// 获取所有数据
        /// </summary>
        /// <returns>数据集合</returns>
        public List<LineBalance> All()
        {
            return DbHelper.All<LineBalance>().ToList();
        }

        /// <summary>
        /// 选择部分数据
        /// </summary>
        /// <param name="wherePartial">条件语句</param>
        /// <param name="orderByPartial">排序语句</param>
        /// <param name="pms">变量</param>
        /// <returns>数据集合</returns>
        public List<LineBalance> Select(string wherePartial = null, string orderByPartial = null, Dictionary<string, object> pms = null)
        {
            return DbHelper.Select<LineBalance>(wherePartial, orderByPartial, pms).ToList();
        }

        /// <summary>
        /// 数量统计
        /// </summary>
        /// <param name="wherePartial">条件语句</param>
        /// <param name="pms">变量</param>
        /// <returns>统计结果</returns>
        public int Count(string wherePartial = null, Dictionary<string, object> pms = null)
        {
            return DbHelper.Count<LineBalance>(wherePartial, pms);
        }
        /// <summary>
        /// 插入数据
        /// </summary>
        /// <param name="model">实体</param>
        /// <returns>影响记录数</returns>
        public int Insert(LineBalance model)
        {
            return DbHelper.Insert<LineBalance>(model);
        }

        /// <summary>
        /// 插入数据
        /// </summary>
        /// <param name="modelList">实体列表</param>
        /// <returns>影响记录数</returns>
        public int Insert(List<LineBalance> modelList)
        {
            return DbHelper.Insert<LineBalance>(modelList);
        }

        /// <summary>
        /// 更新数据
        /// </summary>
        /// <param name="model">实体</param>
        /// <returns>影响记录数</returns>
        public int Update(LineBalance model)
        {
            return DbHelper.Update<LineBalance>(model);
        }

        /// <summary>
        /// 更新数据
        /// </summary>
        /// <param name="modelList">实体列表</param>
        /// <returns>影响记录数</returns>
        public int Update(List<LineBalance> modelList)
        {
            return DbHelper.Update(modelList);
        }

        /// <summary>
        /// 删除数据
        /// </summary>
        /// <param name="model">实体</param>
        /// <returns>影响记录数</returns>
        public int Delete(LineBalance model)
        {
            return DbHelper.Delete<LineBalance>(model);
        }

        /// <summary>
        /// 删除数据
        /// </summary>
        /// <param name="modelList">实体列表</param>
        /// <returns>影响记录数</returns>
        public int Delete(List<LineBalance> modelList)
        {
            return DbHelper.Delete<LineBalance>(modelList);
        }

        /// <summary>
        /// 删除数据
        /// </summary>
        /// <param name="id">数据主键</param>
        /// <returns>影响记录数</returns>
        public int Delete(int id)
        {
            LineBalance model = new LineBalance() { Id = id };
            return Delete(model);
        }
        /// <summary>
        /// 删除数据
        /// </summary>
        /// <param name="ids">数据主键列表</param>
        /// <returns>影响记录数</returns>
        public int Delete(List<int> ids)
        {
            List<LineBalance> modelList = new List<LineBalance>();
            ids.ForEach(a =>
            {
                modelList.Add(new LineBalance() { Id = a });
            });
            return Delete(modelList);
        }
    }
}
